package com.hjxr.xmgl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.net.InetAddress;
import java.net.UnknownHostException;
/**
 * 启动程序
 *
 * @author sun
 */
@EnableSwagger2
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class
})
@ComponentScan(basePackages = {"com.hjxr.common", "com.hjxr.framework", "com.hjxr.sysadmin", "com.hjxr.xmgl"})
//, "com.hjxr.quota"
public class HsqyApplication {
    private static Logger logger = LoggerFactory.getLogger(HsqyApplication.class);

    public static void main(String[] args) throws UnknownHostException {
        System.setProperty("spring.devtools.restart.enabled", "false");
//        SpringApplication.run(hsqyApplication.class, args);
        Environment env = new SpringApplication(HsqyApplication.class).run(args).getEnvironment();
        String envPort = env.getProperty("server.port");
        String envContext = env.getProperty("server.contextPath");
        String port = envPort == null ? "8080" : envPort;
        String context = envContext == null ? "" : envContext;
        String path = port + "" + context + "/doc.html";
        String externalAPI = InetAddress.getLocalHost().getHostAddress();
        System.out.println("启动成功");

        logger.info(
                "Access URLs:\n----------------------------------------------------------\n\t"
                        + "Local-API: \t\thttp://127.0.0.1:{}\n\t"
                        + "External-API: \thttp://{}:{}\n\t"
//                        + "web-URL: \t\thttp://127.0.0.1:{}/index.html"
                        + "\n----------------------------------------------------------",
                path, externalAPI, path);
    }
}
